<template>
	<div class="components-container">
        <div class="header-form">

             <div class="layui-inline">
                <label class="layui-form-label">名称</label>
                 <div class="layui-input-inline">
                    <el-input  v-model="selectData.sicnameLike" placeholder="请输入服务种类名称"></el-input>
                 </div>
            </div>
             <div class="layui-inline">
                <label class="layui-form-label">排序</label>
                 <div class="layui-input-inline">
                    <el-input  v-model="selectData.sicnumLike" placeholder="请输入排序"></el-input>
                 </div>
            </div>
            
            <el-button type="primary"  @click="btnSearch">搜索</el-button>
            <el-button @click="btnRepeat" >重置</el-button>
        </div>
         <!-- 功能列表 -->
        <div>
            <ul class="toolList">
                <li v-if="btnShow(item.BTNVALUE)" v-for="(item, index) in $store.state.btnListCommon" @click="operate(item.BTNVALUE)">
                    <el-button type="primary" :value="item.BTNSHOWNAME" v-text="item.BTNSHOWNAME"></el-button>
                </li>
            </ul>
        </div>
        <!--数据列表-->
        <dataTable :headList="headList" :dataList="dataList" :pageOrder="pageOrder" @pageChange="pageChange" @selectRow="selectRow"></dataTable>

        <serviceTypesManageMain ref="sweetModalMain" :orderType="order" @refreshData="getData"></serviceTypesManageMain>

        <staEndUse ref="useMain" @refreshData="getData"></staEndUse>
	</div>
</template>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/common.scss";
.el-button + .el-button {
  margin-left: 0;
}
.btnCenter {
  text-align: center;
}
</style>
<script>
import serviceTypesManageMain from "./serviceTypesManageMain";
import staEndUse from "./staEndUse";
import dataTable from "@/components/Table/DataTable";
import apiBase from "@/api/apiBase.js";
import { manage } from "@/mixins/managePage.js";
import { ORDER } from "@/const/orderConst.js";

const ADD = "新增";
const MODIFY = "修改";
const DELETE = "删除";
const INFO = "详情";

export default {
  name: "serviceTypesManage",
  mixins: [manage],
  data() {
    return {
      selectData: {},
      Data: {}
    };
  },
  methods: {
    //功能操作
    operate(order) {
      this.order = order;
      this.dataRepeat();
      switch (this.order) {
        case ADD:
          this.$refs.sweetModalMain.open(this.order);
          break;
        case MODIFY:
        case INFO:
        case DELETE:
          this.$refs.sweetModalMain.open(this.order,this.currentRow.SICID);
          break;
        case ORDER.START:
        case ORDER.END:
          this.$refs.useMain.open(this.order, this.currentRow.SICID);
          break;
        default:
      }
    },
    //获取表头
    getColumns() {
      apiBase.DoService(
        {},
        apiBase.getApiAdress().Column.GetServicecategoryColumns,
        res => {
          this.headList = res.data.content;
        }
      );
    },
    //获取查询数据
    getData() {
      let Data = JSON.parse(JSON.stringify(this.selectData));
      var data = {
        PageIndex: this.pageOrder.currentPage,
        PageSize: this.pageOrder.pageSize,
        OrderBy: this.pageOrder.orderType,
        OrderByType: this.pageOrder.orderSort,
        Data: Data
      };
      apiBase.DoService(
        data,
        apiBase.getApiAdress().Servicecategory.Query,
        res => {
          this.dataList = res.data.content.OutData;
          this.pageOrder.totalNum = res.data.content.RecordCount;
        }
      );
    },
    //查询条件重置
    btnRepeat() {
      this.selectData = {};
      this.getData();
    },
    //数据重置
    dataRepeat() {
      this.Data = {};
    }
  },
  mounted() {},
  components: {
    serviceTypesManageMain,
    staEndUse,
    dataTable
  },
  created() {
    this.getColumns();
    this.getData();
  }
};
</script>